package com.qinghe.pro.service.main.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qinghe.pro.entity.main.LogInfo;
import com.qinghe.pro.mapper.main.LogInfoMapper;
import com.qinghe.pro.service.main.LogInfoService;
import com.qinghe.utils.Page;

@Service("logInfoServiceImpl")
public class LogInfoServiceImpl implements LogInfoService {

	@Autowired
	private LogInfoMapper logInfoMapper;

	@Override
	public LogInfo get(Integer id) {
		return logInfoMapper.selectByPrimaryKey(id);
	}

	@Override
	public void insert(LogInfo logInfo) {
		logInfoMapper.insertSelective(logInfo);
	}

	@Override
	public void delete(Integer id) {
		logInfoMapper.deleteByPrimaryKey(id);
	}

	@Override
	public List<LogInfo> findByPage(LogInfo logInfo, Page page) {
		PageHelper.startPage(page.getPageNum(), page.getNumPerPage()).setOrderBy("create_time desc");
		List<LogInfo> list = logInfoMapper.selectAll(logInfo);
		PageInfo<LogInfo> p = new PageInfo<LogInfo>(list);
		page.setTotalCount((int) p.getTotal());
		return list;
	}

}
